import {Descriptions, Modal} from 'antd';
import styles from "../styles.less";

const DataDetail = (props) => {

  const {dataDetail, setDataDetail} = props.data;

  /* 取消操作 */
  function onCancel() {
    setDataDetail(undefined);
  }

  if (!dataDetail || !dataDetail.data) {
    return null;
  }

  return (
    <Modal
      title={dataDetail ? dataDetail.title : ''}
      open={dataDetail ? dataDetail.visible : false}
      onCancel={onCancel}
      forceRender={true}
      width={960}
      className={styles.myModal}
      styles={{body: {maxHeight: 540, overflowY: 'auto'}}}
      footer={null}
    >
      <Descriptions
        size={'small'} column={2} layout={'vertical'}
        labelStyle={{color: '#999'}}
      >
        <Descriptions.Item label='方法名称'>
          {dataDetail.data.methodName ? dataDetail.data.methodName : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='操作状态'>
          {dataDetail.data.status === 0 ? '异常' : '正常'}
        </Descriptions.Item>
        <Descriptions.Item label='操作人员'>
          {dataDetail.data.username ? dataDetail.data.username : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='错误消息'>
          {dataDetail.data.errorMsg ? dataDetail.data.errorMsg : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='业务类型'>
          {dataDetail.data.bizType ? dataDetail.data.bizType : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='业务名称'>
          {dataDetail.data.bizName ? dataDetail.data.bizName : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='请求方式'>
          {dataDetail.data.reqMethod ? dataDetail.data.reqMethod : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='请求URL'>
          {dataDetail.data.reqUrl ? dataDetail.data.reqUrl : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='请求IP地址'>
          {dataDetail.data.ipAddr ? dataDetail.data.ipAddr : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='IP ID'>
          {dataDetail.data.ipId}
        </Descriptions.Item>
        <Descriptions.Item label='操作时间'>
          {dataDetail.data.createTime ? dataDetail.data.createTime : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='关联ID'>
          {dataDetail.data.relativeId === '' ? '暂无' : dataDetail.data.relativeId}
        </Descriptions.Item>
        <Descriptions.Item label='UA' span={2}>
          {dataDetail.data.ua ? dataDetail.data.ua : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='请求参数' span={2}>
          {dataDetail.data.reqBody ? dataDetail.data.reqBody : '暂无'}
        </Descriptions.Item>
        <Descriptions.Item label='响应信息' span={2}>
          {dataDetail.data.resBody ? dataDetail.data.resBody : '暂无'}
        </Descriptions.Item>
      </Descriptions>
    </Modal>
  );
};


export default DataDetail;

